
<html>

<head>
    <include file="public@head" title="导航管理" keywords="后台管理系统"/>
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>
<div class="layui-body">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('tdadmin/index/index')}">主页</a>
        <a>系统设置</a>
        <a href="{:url('index')}">导航管理</a>
        <a href="{:url('add')}"><cite>添加导航</cite></a>
    </div>

    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">
                添加导航
            </div>
            <div class="layui-card-body layui-row">
                <form method="post" class="layui-form layui-col-md8 layui-col-lg6" action="{:url('add')}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">父级名称</label>
                        <div class="layui-input-inline">
                            <select name="pid" lay-filter="menu" class="layui-select">
                                <option value="0">--默认顶级--</option>
                                <foreach name="nav_list" item="vo">
                                    <option
                                    <if condition="$pid eq $vo['id']"> selected="selected"</if>
                                    value="{$vo.id}">{$vo.str}{$vo.name}
                                    </option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">URL<span class="form-required">*</span></label>
                        <div class="layui-input-inline">
                            <select name="urlSelect" lay-filter="url">
                                <option value="">请选择</option>
                                <option data-name="首页" value="/">首页</option>
                                <optgroup label="文章分类">
                                    <foreach name="categorys" item="vo">
                                        <option value="{:url('index/list/index',array('id'=>$vo.id))}">{$vo.name}
                                        </option>
                                    </foreach>
                                </optgroup>
                                <optgroup label="所有单页">
                                    <foreach name="pages" item="vo">
                                        <option value="{:url('index/page/index',array('id'=>$vo.id))}">{$vo.title}
                                        </option>
                                    </foreach>
                                </optgroup>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="url" lay-verify="required" lay-verType="tips"
                                   placeholder="请填写http://地址">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航名称<span class="form-required">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="name" lay-verify="required" lay-verType="tips"
                                   placeholder="请输入导航名称">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航标题</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="title" placeholder="请输入导航标题">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="input-target" class="layui-form-label">打开方式</label>
                        <div class="layui-input-block">
                            <input type="radio" name="target" value="_blank" title="新标签页打开" checked="checked">
                            <input type="radio" name="target" value="_self" title="本窗口打开">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="input-status" class="layui-form-label">是否显示</label>
                        <div class="layui-input-inline">
                            <input type="radio" name="status" value="1" title="启用" checked="checked">
                            <input type="radio" name="status" value="0" title="禁用">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="number" name="list_order" value="0" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn" lay-submit lay-filter="general">添加</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">返回</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<include file="public@scripts"/>
<script>
    form.on('select(url)', function (data) {
        if (data.value) {
            $("input[name='url']").val(data.value);
            $("input[name='name']").val(data.elem[data.elem.selectedIndex].text);
            $("input[name='url']").attr('readonly', 'readonly');
        }
        else {
            $("input[name='url']").val('');
            $("input[name='name']").val('');
            $("input[name='url']").removeAttr('readonly');
        }
    });
</script>
</body>

</html>
